Xbasic
Array upper Method
Syntax
dim result as N = <array>.upper()
Returns
- resultNumeric
The upper bound of the array - this is the index of the last element in the array.
Description
Returns the upper bound of the array.
Discussion
Arrays can be defined with custom indexes. For example:
dim rarr[2..5] as c
The Xbasic array rarr is defined with a lower bound of 2 and upper bound of 5. This means the index of the last element in the array is 5. The <array>.upper() method can be used to get the upper bound for an array. This is useful for getting the index of the last item in the array when the lower bound is not 1 and <array>.size() cannot be used to iterate through the values in the array.
dim rarr[2..5] as c for i = rarr.lower() to rarr.upper() rarr[i] = "value"+i next ? rarr = [2] = "value2" [3] = "value3" [4] = "value4" [5] = "value5" ? rarr.size() = 4
See Also